home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Oberon⁄F™ 1.1 / Obx / Docu / Hello0 (.txt) < prev    next >
Encoding:
Oberon Document  |  1996-01-05  |  6.2 KB  |  76 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. Helvetica
  17. Helvetica
  18. Helvetica
  19. Helvetica
  20. TextRulers.StdRulerDesc
  21. TextRulers.RulerDesc
  22. TextRulers.StdStyleDesc
  23. TextRulers.StyleDesc
  24. TextRulers.AttributesDesc
  25. MODULE ObxHello0;
  26.     IMPORT Out;
  27.     PROCEDURE Do*;
  28.     BEGIN
  29.         Out.String("Hello World"); Out.Ln    (* write string and 0DX into log *)
  30.     END Do;
  31. END ObxHello0.
  32. TextControllers.StdCtrlDesc
  33. TextControllers.ControllerDesc
  34. Containers.ControllerDesc
  35. Controllers.ControllerDesc
  36. Helvetica
  37. DevCommanders.StdViewDesc
  38. DevCommanders.ViewDesc
  39. Oberon by Example: ObxHello0
  40. After you have started Oberon/F, you can open the file Hello0 in the Docu directory of the Obx directory. It contains exactly the text you are now reading.
  41. A first example of an Oberon module is given below, as an embedded text object:
  42. To compile this module, it must first be focused (i.e. set the caret or selection in it). This is done by clicking somewhere in the object. Then execute the Compile command in the Dev menu. After the compilation, a message like
  43. compiling "ObxHello0"
  44.   new symbol file   96   0
  45. appears in the Log window. It means that module ObxHello0 has been compiled successfully, that a code file has been written to disk containing the compiled code, that this module has a code size of 96 bytes and global variables of 0 bytes size, and that information about the module's interface has been written to disk in a symbol file. New symbol files are created whenever a module is compiled for the first time, or when its interface has changed.
  46. The interface of the above module consists of one exported procedure: ObxHello0.Do. In order to call this procedure, a commander can be used (the little button below):
  47.  ObxHello0.Do
  48. Click on this button to cause the following actions to occur: the code for ObxHello0 is loaded into memory, and then its procedure Do is executed. You see the result in the log window:
  49. Hello World
  50. When you click on the button again, Oberon/F executes the command immediately, without loading the module's code again: once loaded, modules remain loaded unless they are explicitly removed.
  51. When clicked, a commander takes the string which follows it, and tries to interpret it as an Oberon command, i.e. as a module name followed by a dot, followed by the name of an exported, parameterless procedure.
  52. Try out the following examples:
  53.  DevCmds.ClearLog    
  54.  Dialog.Beep     
  55.  DevDebug.ShowLoadedModules
  56. The list of loaded modules can be inspected by executing the Loaded
  57. Modules command in the Info menu, or by simply clicking in the appropriate commander above. It will generate a text similar to the following:
  58. module name    bytes used    clients    compiled    loaded
  59. ObxHello0    
  60. 0    25.10.1994  20:07:08    25.10.1994  20:08:42
  61. 1    24.10.1994  13:53:49    25.10.1994  20:08:42
  62. Config    
  63. 0    24.10.1994  13:53:47    25.10.1994  18:31:52
  64. A module can be unloaded if its client count is zero, i.e. if it is imported by no other modules. In order to unload ObxHello0, focus its source text again and then execute Unload in the Dev menu. The following message will appear in the log window:
  65. unload modules:
  66.     ObxHello0
  67. When you generate the list of loaded modules again, it will look as follows:
  68. module name    bytes used    clients         compiled         loaded
  69. 0    24.10.1994  13:53:49    25.10.1994  20:08:42
  70. Config    
  71. 0    24.10.1994  13:53:47    25.10.1994  18:31:52
  72. Note that a module list is just a text which shows a snapshot of the loader state at a given point in time, it won't be updated when you load or unload modules. You can print the text, save it in a file, or edit it without danger that it may be changed by the system.
  73. In this first example, we have seen how a very simple Oberon/F module looks like, how it can be compiled, how its command can be executed, how commanders are used as convenient alternatives to menu entries during development, how the list of loaded modules can be inspected, and how a loaded module can be unloaded again.
  74. Helvetica
  75. Documents.ControllerDesc
  76.